from django.db import models

# from libs.base_model import BaseModel
from code_monkey.libs.base_model import BaseModel
from users.models import User


class Complain(BaseModel):
    """
    吐槽列表
    """
    user_id = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE)
    content = models.TextField(verbose_name='内容')
    like_count = models.IntegerField(verbose_name='点赞量', default=0)
    comment_count = models.IntegerField(verbose_name='评论量', default=0)
    cover = models.CharField(max_length=128, verbose_name='图片')

    class Meta:
        db_table = 'tb_complains'
        verbose_name = '吐槽列表'
        verbose_name_plural = verbose_name


class Comment(BaseModel):
    user_id = models.ForeignKey(User, related_name='Comment.user+', verbose_name='用户', on_delete=models.CASCADE)
    complain_id = models.ForeignKey(Complain, verbose_name='评论吐槽', related_name="comment",on_delete=models.CASCADE)
    content = models.TextField(verbose_name='内容')
    comment_like_count = models.IntegerField(verbose_name='评论点赞量', default=0)

    class Meta:
        db_table = 'tb_comments'
        verbose_name = '评论列表'
        verbose_name_plural = verbose_name


class Collection(BaseModel):
    user_id = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE)
    complain_id = models.ForeignKey(Complain, verbose_name='吐槽编号', on_delete=models.CASCADE)

    class Meta:
        db_table = 'tb_collections'
        verbose_name = '收藏'
        verbose_name_plural = verbose_name


class ComplainLike(BaseModel):
    user_id = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE)
    complain_id = models.ForeignKey(Complain, verbose_name='吐槽编号', on_delete=models.CASCADE)

    class Meta:
        db_table = 'tb_complains_like'
        verbose_name = '吐槽点赞'
        verbose_name_plural = verbose_name


class CommentLike(BaseModel):
    user_id = models.ForeignKey(User, verbose_name='用户', on_delete=models.CASCADE)
    comment_id = models.ForeignKey(Comment, verbose_name='评论编号', on_delete=models.CASCADE)

    class Meta:
        db_table = 'tb_comments_like'
        verbose_name = '评论点赞'
        verbose_name_plural = verbose_name
